<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#assign css>
<style>
</style>
</#assign>
<#assign js>
<script>
	function del(id) {
		layer.confirm('确定删除吗?', {icon: 3, title: '提示'}, function (index) {
			$.ajax({
				type: "POST",
				dataType: "json",
				url: "/weather/delete/" + id,
				success: function (res) {
					layer.msg(res.message, {time: 2000}, function () {
						location.reload();
					});
				}
			});
		});
	}

    function stop(id) {
        layer.confirm('确定立即停止吗?', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/weather/stop/" + id,
                success: function (res) {
                    layer.msg(res.message, {time: 2000}, function () {
                        location.reload();
                    });
                }
            });
        });
    }

	//tableId,queryId,conditionContainer
	//var userTable;
	var winId="userWin";
	$(function() {
		//init table and fill data
		//userTable = new CommonTable("user_table", "user_list", "searchDiv");

		//button event
		$('button[data-btn-type]').click(function() {
			var action = $(this).attr('data-btn-type');
			var rowId="ceshi";
			switch (action) {
				case 'add':
					modals.openWin({
						winId:winId,
						title:'新增特殊天气设置',
						width:'900px',
						url:"/weather/edit/ceshi"
					});
					break;
				case 'edit':
					if(!rowId){
						modals.info('请选择要编辑的行');
						return false;
					}
					modals.openWin({
						winId:winId,
						title:'编辑特殊天气设置【'+userTable.getSelectedRowData().name+'】',
						width:'900px',
						url:"/weather/edit/"+rowId,
					});
					break;
				case 'delete':
					if(!rowId){
						modals.info('请选择要删除的行');
						return false;
					}
					modals.confirm("是否要删除该行数据？",function(){
						ajaxPost(basePath+"/weather/delete/"+rowId,null,function(data){
							if(data.success){
								//modals.correct("已删除该数据");
								userTable.reloadRowData();
							}else{
								modals.error("特殊天气设置数据被引用，不可删除！");
							}
						});
					})
					break;
			}

		});
		//form_init();
	});
</script>
</#assign>
<@layout title="特殊天气设置管理" active="weather">
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        分站特殊天气设置列表
    </h1>
    <ol class="breadcrumb">
        <li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
        <li><a href="/category/index"><i class="fa fa-list-ul"></i> 物品品类</a></li>
        <li class="active"><i class="fa fa-table"></i> 物品品类列表</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">
	<!-- Default box -->
	<div class="box box-primary">
		<div class="box-header">
        <@shiro.hasPermission name="system:weather:add">
			<a class="btn btn-sm btn-success" href="/weather/add">新增</a>
        </@shiro.hasPermission>
		</div>
		<div class="box-body">
			<table class="table table-striped">
				<tr>
					<th>序号</th>
					<th>天气描述</th>
					<th>开始时间</th>
					<th>结束时间</th>
					<th>特殊天气奖励金额</th>
					<th>设置时间</th>
					<th>设置人</th>
                    <th>状态</th>
					<th>操作</th>
				</tr>
                <#list pageInfo.list as item>
                <tr>
					<td >${item.id!}</td>
					<td  >${item.weatherDesc!}</td>
					<td >${(item.startTime?string('yyyy-MM-dd HH:mm:ss'))!}</td>
					<td >${(item.endTime?string('yyyy-MM-dd HH:mm:ss'))!}</td>
					<td >${item.reward!}</td>
					<td >${(item.createAt?string('yyyy-MM-dd HH:mm:ss'))!}</td>
					<td >${item.createBy!}</td>
					<td >
						<#if item.status=='0' >
							<span class="label label-default">已过期</span>
						</#if>
						<#if item.status=='1' >
							<span class="label label-danger">进行中</span>
						</#if>
						<#if item.status=='2' >
							<span class="label label-info">未生效</span>
						</#if>
					</td>

					<td>
					<@shiro.hasPermission name="system:weather:stop">
						<#if item.status=='1' >
							<a class="btn btn-sm btn-danger" onclick="stop(${item.id})" data-btn-type="detail">立即停止</a>
						</#if>
                    </@shiro.hasPermission>
					<@shiro.hasPermission name="system:weather:delete">
						<#if item.status=='2' >
							<a class="btn btn-sm btn-danger" onclick="del(${item.id})" data-btn-type="detail">删除</a>
						</#if>
					</@shiro.hasPermission>


					</td>
				</tr>
                </#list>
			</table>
		</div>
		<!-- /.box-body -->
		<div class="box-footer clearfix">
            <@macro.page pageInfo=pageInfo url="/weather/index?" />
		</div>
	</div>
	<!-- /.box -->

</section>
<!-- /.content -->
</@layout>
